package com.magic.gre.ui.dialog;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.view.View;

import com.magic.gre.R;
import com.magic.gre.base.dialog.BaseBottomDialog;
import com.magic.gre.utils.ShareUtils;
import com.noname.lib_base_java.util.ToastUtil;

/**
 * Author: Lmoumou
 * Date: 2019-01-04 16:30
 * 文件名: ShareDialog
 * 描述:
 */
public class ShareDialog extends BaseBottomDialog implements ShareUtils.ShareInterface {
    private String title;
    private String content;
    private String url;
    private String image;
    private ShareUtils shareUtils;

    @Override
    protected int setViewId() {
        return R.layout.dialog_share2;
    }


    public void showThis(FragmentManager manager, String tag, String title, String content, String url, String image) {
        super.showThis(manager, tag);
        this.title = title;
        this.content = content;
        this.url = url;
        this.image = image;
    }

    @Override
    protected void initView(View view) {

        shareUtils = new ShareUtils(this);

        view.findViewById(R.id.wx_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                shareUtils.doWechat(title, content, url, image);
            }
        });
        view.findViewById(R.id.friend_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                shareUtils.doWechatMoment(title, content, url, image);
            }
        });
        view.findViewById(R.id.qq_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                shareUtils.doQQ(title, content, url, image);
            }
        });

        view.findViewById(R.id.sina_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                shareUtils.doSina(title, content, url, image);
            }
        });
    }

    @Override
    protected void initBundle(Bundle bundle) {

    }

    @Override
    public void shareSuccess() {
        ToastUtil.getInstance().showNormal(getContext(), "分享成功");
    }

    @Override
    public void shareFailed() {
        ToastUtil.getInstance().showNormal(getContext(), "分享失败");
    }
}
